import { createRouter, createWebHistory } from 'vue-router';
import BuildPage from '../views/BuildPage.vue';
import DraftPage from '../views/DraftPage.vue';

const routes = [
  {
    path: '/',
    name: 'Build',
    component: BuildPage,
    meta: {
      title: '构建页面'
    }
  },
  {
    path: '/draft',
    name: 'Draft',
    component: DraftPage,
    meta: {
      title: '草稿箱管理'
    }
  }
];

const router = createRouter({
  history: createWebHistory(),
  routes
});

// 路由守卫 - 设置页面标题
router.beforeEach((to, from, next) => {
  if (to.meta.title) {
    document.title = `${to.meta.title} - GitBuild 自动化打包系统`;
  }
  next();
});

export default router;
